package Demo9;

import java.util.concurrent.ArrayBlockingQueue;

public class ThreadDemo {
    /**
     * 使用阻塞队列实现生产者消费者模型
     *
     */
    public static int count = 0;
    public static void main(String[] args) {
        ArrayBlockingQueue<String> queue = new ArrayBlockingQueue<>(1);
        Consumer consumer = new Consumer(queue);
        Producer producer = new Producer(queue);


        consumer.setName("消费者");
        producer.setName("生产者");
        consumer.start();
        producer.start();
    }
}
